import {
  CardAirdropDto,
  CardCreateDto,
  CardFindDto,
  CardListDto,
  CardQueryDto,
  CardRemoveDto,
  CardUpdateDto,
} from '@/dtos';
import { CardService } from '@/services/card.service';
import { ok } from '@/utils';
import { Body, Controller, Delete, Patch, Post, Query } from '@nestjs/common';
import { BaseController } from './base.controller';
import { CurrentUser } from '@/decorators';

@Controller('card')
export class CardController extends BaseController {
  constructor(private readonly cardService: CardService) {
    super();
  }

  @Post('list')
  async list(@Body() dto: CardListDto, @CurrentUser('id') userId: number) {
    return ok(await this.cardService.list(dto, userId));
  }

  @Post('admin/query')
  async query(@Body() dto: CardQueryDto) {
    return ok(await this.cardService.query(dto));
  }

  @Post('admin/find')
  async find(@Body() dto: CardFindDto) {
    return ok(await this.cardService.findOne(dto.where, dto.select));
  }

  @Post('admin/create')
  async create(@Body() dto: CardCreateDto) {
    return ok(await this.cardService.create(dto.data));
  }

  @Patch('admin/update')
  async update(@Body() dto: CardUpdateDto) {
    return ok(await this.cardService.update(dto));
  }

  @Delete('admin/remove')
  async remove(@Query() dto: CardRemoveDto) {
    return ok(await this.cardService.remove(dto));
  }

  @Post('admin/airdrop')
  async airdrop(@Body() dto: CardAirdropDto) {
    return ok(await this.cardService.airdrop(dto));
  }
}
